#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e5 + 10;

int n;
long long arr[N];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    long long ret = 1e16 + 10;
    for (int i = 1; i < n; i++)
    {
        ret = min(ret, arr[i] - arr[i - 1]);
    }
    cout << ret << endl;
    return 0;
}